<script>
    import { onMount } from 'svelte';
    import List from '../components/list.svelte';
    import Btn from '../components/btn.svelte';
    import QueryBar from '../components/queryBar.svelte';
    import Paging from '../components/paging.svelte';
    import Query from '../model/query.js';
    import { Post } from '../lib/net.js';
    import { PlatformAssetList,AgentAdd} from '../api.js';

    let listData = {
        title: ["操作记录","用户UID","姓名","手机号","代理人","USDT数量","时间","状态"],
        data: []
    }

    let map_type = ["充值", "提币", "划转", "划转", "盈利",  "赔付" ];

    let map_state = ["待审核","进行中","已完成","已取消","提现拒绝"];

    let query = new Query();
    let vfunds=10000
    onMount(()=>{
        getList()
    });


    async function getList(e){

       if (e) {
            query.start = e.detail.start
            query.end = e.detail.end
       }
        let ret = await Post(PlatformAssetList,query);
        console.log(ret)

        query.total = ret.total;
        query.page = ret.page;
        vfunds=ret.Extra.balance

        let data = [];
        for(let item of ret.list) {
            let arr = [map_type[item.type],item.uid,item.name,item.phone,item.agent,item.amount,item.show_operate_date,map_state[item.state]]
            arr.href = "/platform/assets/detail" + "?tid=" + item.tid;
            data.push(arr);
        }
        listData.data = data;
    }

    function setPage(page){
        query.page = page;
        getList();
    }

</script>

<div class="view">
    <div class="container backBlue colorWhite borderRadius">
        <div class="columns">
            <div class="column is-2">
                <nav class="level">
                    <div class="level-item has-text-centered">
                        <div style="margin-left: 20px">
                            <p class="heading">平台总资金</p>
                            <p class="font25 colorWhite">{vfunds}</p>
                        </div>
                    </div>
                </nav>
            </div>
        </div>
    </div>
    <div class="container">
        <QueryBar query={query} on:message={getList}/>
    </div>
    <div class="container">
        <List data={listData}/>
    </div>
    <div class="container">
        {#if query.total !== 0}
        <Paging page={query} handler={setPage}/>
        {/if}
    </div>
</div>

<style>
    /*.allMoney{*/
        /*width:550px;*/
        /*background-image: url("images/platformMoney.png") norepeat;*/
        /*background-size: cover;*/
    /*}*/
    .container {
        margin: 20px;
    }
</style>
